(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseHousekeepingType: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseHousekeepingTypeInfo: {
                housekeepingTypes: [],
                _currentHousekeepingTypeName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseHousekeepingType', 'openChooseHousekeepingTypeModel', function (_param) {
                $('#chooseHousekeepingTypeModel').modal('show');
                $that._refreshChooseHousekeepingTypeInfo();
                $that._loadAllHousekeepingTypeInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllHousekeepingTypeInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('/housekeepingType.queryHousekeepingType',
                    param,
                    function (json) {
                        var _housekeepingTypeInfo = JSON.parse(json);
                        $that.chooseHousekeepingTypeInfo.housekeepingTypes = _housekeepingTypeInfo.housekeepingTypes;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseHousekeepingType: function (_housekeepingType) {
                if (_housekeepingType.hasOwnProperty('name')) {
                    _housekeepingType.housekeepingTypeName = _housekeepingType.name;
                }
                vc.emit($props.emitChooseHousekeepingType, 'chooseHousekeepingType', _housekeepingType);
                vc.emit($props.emitLoadData, 'listHousekeepingTypeData', {
                    housekeepingTypeId: _housekeepingType.housekeepingTypeId
                });
                $('#chooseHousekeepingTypeModel').modal('hide');
            },
            queryHousekeepingTypes: function () {
                $that._loadAllHousekeepingTypeInfo(1, 10, $that.chooseHousekeepingTypeInfo._currentHousekeepingTypeName);
            },
            _refreshChooseHousekeepingTypeInfo: function () {
                $that.chooseHousekeepingTypeInfo._currentHousekeepingTypeName = "";
            }
        }

    });
})(window.vc);
